<template>
  <div class="set-root">
    <div class="form">
      <div>标题</div>
      <input type="text" v-model="config.name">
      <div>每次抽取个数</div>
      <input type="text" v-model="config.num">
    </div>
    <div class="btns">
      <button autofocus @click="confirm">确认</button>
      <button type="button" @click="cancel">取消</button>
    </div>
  </div>
</template>
<script setup>
import { ref } from 'vue'
import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
const win = WebviewWindow.getCurrent();
win.once('set-config', (event) => {
  config.value = event.payload;
});
win.emit('ok-config');

const confirm = () => {
  win.emit('get-config', config.value);
  win.close();
}

const config = ref({
  name: '',
  num: 1
});
const cancel = () => {
  win.close();
}

</script>
<style lang="scss" scoped>
.set-root {
  font-family: '新宋体', sans-serif;
  box-sizing: border-box;
  width: 100%;
  height: 287px;
  font-size: 32px;
  font-weight: bold;

  padding: 10px;
  position: relative;

  .form {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 450px;
    gap: 10px;
    box-sizing: border-box;
  }

  * {
    font-size: inherit;
    text-align: left;
    font-weight: inherit;
    font-family: inherit;
    box-sizing: border-box;
  }

  .btns {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
  }
}
</style>